<template>
    <div class="emailchange">
        <div>
            <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px"
                     class="demo-ruleForm">
                <el-form-item label="当前邮箱：" prop="compemail" style="width: 0px">
                    <el-input v-text="ruleForm.useremail" ></el-input>
                </el-form-item>
                <el-form-item label="新邮箱：" prop="newemail">
                    <el-input placeholder="请输入新的邮箱" type="text" v-model="ruleForm.newemail"
                              autocomplete="off"  style="width: 300px">
                    </el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" style="width: 150px" @click="submitForm('ruleForm')">修改邮箱</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>
<script>
    export default {
        name: 'emailchange',
        data() {
            return {
                ruleForm: {
                    useremail: '92****232@qq.com',
                    newemail: '',
                },
                rules: {
                    newemail: [
                        {required: true, message: '请输入新邮箱', trigger: 'blur'},
                        {type: 'email', message: '请输入正确的邮箱', trigger: ['blur', 'change']}
                    ],
                }
            }
        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        alert('submit!');
                    } else {
                        return false;
                    }
                });
            },
        }
    }
</script>

<style scoped>
    .emailchange {
        display: flex;
        flex-direction: row;
        justify-content: center;
        margin-top: 5%;

    }
</style>
